package com.zaydanwu.cla.controller.students;

import com.zaydanwu.cla.model.News;
import com.zaydanwu.cla.model.result.ApiResult;
import com.zaydanwu.cla.service.NewsService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @BelongsProject: cla
 * @BelongsPackage: com.zaydanwu.cla.controller.students
 * @Author: zaydanwu
 * @CreateTime: 2018-12-10 22:44
 * @Description:
 */
@RestController
@RequestMapping("/cla/api")
public class NewsController {

    @Resource
    private NewsService newsService;

    @RequestMapping("/getAllNews")
    public ApiResult<List<News>> getAllNews() {
        List<News> allNews = newsService.getAllNews();

        return ApiResult.success(allNews);
    }

    @RequestMapping("/saveNews")
    public ApiResult<Object> saveNews(@RequestBody News news) {
        int i = newsService.saveNews(news);
        return ApiResult.success(i);
    }
}
